<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ include file="Logined.jsp" %>
<jsp:useBean id="db" class="connBean.ConnDB" scope="page">
</jsp:useBean>
<link href="images/skin.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html;" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #EEF2FB;
}
-->
table tr{
height:40px;
line-height:40px
}

.tab_content{
border-bottom:1px dashed #cccccc;
border-right:1px dashed #cccccc;
}
.tab_title{
color:#444444;
font-size:20px;
font-weight:bold;
text-align:center;
}
</style>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
    <td valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">用户查询</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>

  <table >
  <tr>
  <td class="tab_title">用户编号</td><td class="tab_title">用户账户</td> <td class="tab_title">用户头像</td>
  <td class="tab_title">邮箱</td> <td class="tab_title">等级</td> <td class="tab_title">操作</td> 
  <td class="tab_title">删除</td> 
  </tr>  
    <%
    
String sql="select * from customer";   
db.OpenConn();
db.createStmt(); 
 ResultSet rs=db.Query(sql);

 
 
 
                //分页实现代码从此开始
				int intPageSize;//一页显示的记录数
				int intRowCount;//记录总数
				int intPageCount;//总页
				int intPage;//待显示页码
				String strPage;
				int i;
				intPageSize = 4;//设置一页显示的记录数
				strPage = request.getParameter("page");//取得待显示页码
				if (strPage == null) {//表明在ＱueryString中没有page这个参数，则显示第一页数据
					intPage = 1;
				} else {//将字符串换成整型
					intPage = Integer.parseInt(strPage);
					if (intPage < 1)
						intPage = 1;
				}

				rs.last();//记录指针指向查询结果集中最后一条记录
				intRowCount = rs.getRow();//获取记录总数
				intPageCount = (intRowCount + intPageSize - 1) / intPageSize;//记录总页数
				if (intPage > intPageCount)
					intPage = intPageCount;//调整待显示的页码
				if (intPageCount > 0) {
					rs.absolute((intPage - 1) * intPageSize + 1);//将记录指针定位到待显示页的第一条记录上．
					//显示数据
					i = 0;
			while(i<intPageSize&&!rs.isAfterLast()){ 
				
				int c_id=rs.getInt("c_id");
			%>
			<tr>
			<td class="tab_content"><%=rs.getString("c_id")%></td>
			<td class="tab_content"><%=rs.getString("c_name")%></td>
			<td class="tab_content">
			<img src="images/<%=rs.getString("c_header")%>" width=100 height=100/>
			</td>	
			
			<td class="tab_content"><%=rs.getString("c_email")%></td>		
			<td class="tab_content">
			
			<% 
			int level=rs.getInt("c_level");
 String isvip="";
 if (level==0){
 isvip="普通用户";}
 else{
 isvip="VIP用户";
 } %>
			<%=isvip%>
			</td>
				<td class="tab_content">
<% 
			
 String setvip="";
 if (level==0){
 setvip="设置VIP";}
 else{
setvip="取消VIP";
 } %>
			<a href="setvip.jsp?setid=<%=c_id %>"><%=setvip%></a>
				</td>
				<td class="tab_content">
					<a href="deletuser.jsp?deleteid=<%=c_id %>">删除</a>
					
				</td>				
				
							
			</tr>
 			<%
				rs.next();
					i++;
				}
			%>

			<tr>
				<td colspan=6>
					第<%=intPage%>页 共<%=intPageCount%>页
					<%
					if (intPage < intPageCount) {
				%>
					<a href="selectuser.jsp?page=<%=intPage + 1%>">下一页</a>
					<%
						}
						if (intPage > 1) {
					%>
					<a href="selectuserjsp?page=<%=intPage - 1%>">上一页</a>
					<%
						}
						}
						rs.close();
                   db.closeConn();
                  db.closeStmt();  
					%>

				</td>




</table>




</td>
</tr>
      
    </table></td>
  </tr>

</table>
</body>

